package com.wang.code.dao;

import com.wang.code.entity.JijinDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;


/**
 * @author wanglei
 * @desc
 * @date 2018/12/6
 * @see
 * @since 1.0
 */
@Repository
public interface JijinRepository extends JpaRepository<JijinDO, Integer> {

    @Modifying
    @Transactional
    @Query("delete from jijin WHERE code = ?1")
    void deleteByCode(String code);

    @Modifying
    @Transactional
    @Query("update jijin set share = ?1, price = ?2 WHERE code = ?3")
    void updateByCode(BigDecimal share, BigDecimal price, String code);

}
